package com.demo.repository;


import com.demo.domain.User;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by wangzhanjin on 2018/5/31.
 * MongoRepository，
 * ReactiveMongoRepository，对应Flux<User>
 */
@Repository
public interface UserRepository extends MongoRepository<User, String> {

    /**
     * 根据年龄查找用户
     * jpa的强大之处，只要写好就会生成
     *
     * @param start
     * @param end
     * @return
     */
    List<User> findByAgeBetween(int start, int end);

    @Query("{'age':{'$gte':20,'$lte':29}}")
    List<User> oldUser();
}
